/*
 * AppletElement.h
 *
 *  Created on: 2010-6-5
 *      Author: Guobc
 */

#ifndef APPLETELEMENT_H_
#define APPLETELEMENT_H_

#include "CommonElement.h"
#include "ParamElement.h"

namespace HA {
class AppletElement: public CommonElement {
public:
	AppletElement();

	/**
	 * Get the set of names handles by this element.
	 * @return The names to be matched that create elements of this type.
	 */
	inline string* getIds() const {
		return mIds;
	}

	/**
	 * Get the set of names that cause this element to finish.
	 * @return The names of following elements that stop further parse.
	 */
	inline string* getEnds() const {
		return mEnds;
	}

	/**
	 * Allow creating an instance of this node.
	 * @return A new instance of this node.
	 */
	inline ASTNode* newInstance() const {
		return new AppletElement();
	}

	/**
	 * Return code attribute of this applet element.
	 * @return The applet class name.
	 */
	inline string getAppletClass() {
		return getAttribute("CODE");
	}

	/**
	 * Modify code base attribute of this applet element.
	 * @param newCodeBase The new valud of code base.
	 */
	inline void setCodeBase(const string& newCodeBase) {
		setAttribute("CODEBASE", newCodeBase);
	}

	/**
	 * Return code base attribute of this applet element.
	 * @return The value of code base.
	 */
	inline string getCodeBase() {
		return getAttribute("CODEBASE");
	}

	/**
	 * Modify the archive attribute of this applet element.
	 * @param newArchive The new value of archive attribute of this applet element.
	 */
	inline void setArchive(const string& newArchive) {
		setAttribute("ARCHIVE", newArchive);
	}

	/**
	 * Return value of archive attribute to this applet element.
	 * @param archive The value of archive.
	 */
	inline string getArchive() {
		return getAttribute("ARCHIVE");
	}

	/**
	 * Get parameter elements in the children list of this element.
	 * @return The children of parameter element.
	 */
	ASTNodeList getParameters();

	/**
	 * Get parameter element with given param element's name attribute value.
	 * @param name The value of name attribute of param element.
	 */
	ParamElement* getParameter(const string& name);

	/**
	 * Add a paremeter element to this element.
	 * @param element The child of this element.
	 */
	inline void addParemeter(ParamElement* element) {
		appendChild(element);
	}

private:
	static string mIds[];
	static string mEnds[];
};
}

#endif /* APPLETELEMENT_H_ */
